package mrusanov.util

import collection.GenTraversable

object CollectionsUtil {
  def insertIntoVector[A](element:A, list:Vector[A], index:Int):Vector[A] = {
    if (index == list.size) {
      list :+ element
    } else {
      val insertedListOfLists = for (kv <- list.zipWithIndex) yield {
        kv match {
          case (current, `index`) => List(element, current)
          case (current, _) => List(current)
        }
      }
      insertedListOfLists.flatten
    }
  }
}
